home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_1 / suite3d < prev    next >
Internet Message Format  |  1995-03-31  |  10KB

  1. Path: seq!spell
  2. From: Charles Patton <charliep@hpcvrs.cv.hp.com>
  3. Subject:  v01i017:  suite3d - 3D Graphing Suite v1.0, Part01/01
  4. Newsgroups: comp.sources.hp48
  5. Followup-To: comp.sys.hp48
  6. Approved: spell@seq.uncwil.edu
  7.  
  8. Checksum:  958952063 (verify with brik -cv)
  9. Submitted-by: Charles Patton <charliep@hpcvrs.cv.hp.com>
  10. Posting-number: Volume 1, Issue 17
  11. Archive-name: suite3d/part01
  12.  
  13. BEGIN_DOC Suite3D.doc
  14. @ Version 1.0 @
  15.  
  16. _Introduction_
  17.  
  18.      The programs contained in this document comprise a suite of 3D
  19. graphing/viewing utilities for the HP-48 (an HP-28 version will be
  20. forthcoming provided sufficient interest.)
  21.  
  22.      We had several requirements to consider in creating these
  23. programs. Our aims were that they be (1) purely user code, (2)
  24. relatively short, and (3) psychologically effective.  Aims (1) and (2)
  25. are due to our target audience of educators, many of whom have little
  26. contact with technology beyond their use of the HP-48 or HP-28. We
  27. expect that, in many situations, one user will obtain the code in
  28. printed form, enter it into their machine, and transmit it to others
  29. via the infrared I/O.
  30.  
  31.      In exploring visualization techniques on a variety of machines we
  32. found that increasing "realism" (read: ray-traced, Phong-shaded,
  33. hidden-line, etc.) in the graphical presentation of functions of two
  34. variables did not necessarily correlate with increasing ease of
  35. comprehension. These programs represent the results of some of these
  36. experiments (including time-to-completion as an important factor).
  37.  
  38.      We invite you to try them out and experiment yourself. All
  39. suggestions, additions, corrections, insights, commentary, and
  40. criticisms are welcome.
  41.  
  42. _Organization_
  43.  
  44.      Analogous to the built-in plotting routines, all the Suite3D
  45. programs assume that the function of interest is stored in EQ.
  46. Further, they assume that the function is represented as an expression
  47. in the variables 'X' and 'Y' (e.g. u,v -> sin(u+v) is represented as
  48. 'SIN(X+Y)' in EQ). Insure that 'X' and 'Y' are formal (no variables
  49. 'X' and 'Y' along the current path).
  50.  
  51.      The viewing window is controlled (as usual) by PMIN and PMAX (or
  52. XRNG and YRNG, though these may be inappropriately named for some
  53. Suite3D programs.)
  54.  
  55.      Some of the programs have an associated <descriptor>PAR variable
  56. analogous to PPAR. Default versions are supplied in this document.
  57.  
  58.      The programs here are organized into a single directory for
  59. convenience.  Inter-dependence of the programs and other variables is
  60. noted in the program description.
  61.  
  62. _Oversized PICTs_
  63.  
  64.      With the sole exception of YVIEW, all of the programs have
  65. assumed that the PICT grob has the default size. Moreover, some of the
  66. parameters coded into the programs were determined experimentally. In
  67. consequence, don't expect any miracles to occur with these programs if
  68. an oversized PICT is used. While it is quite possible encode automatic
  69. scaling from the size of the PICT, we didn't find it useful enough to
  70. include. If anyone has additional insights into this issue, we'd
  71. welcome their input.
  72.  
  73. _Descriptions of the Programs_
  74.  
  75. SlopeField:
  76.      The SlopeField program plots a lattice of line segments whose
  77. slopes represent the function value at their centerpoint. Using
  78. SlopeField to plot F(X,Y) allows your eye to pick out integral curves
  79. of the differential equation dy/dx=F(x,y). It is quite useful in
  80. understanding where the "arbitrary constant" in anti-derivatives comes
  81. from.
  82.  
  83. psContour:
  84.      The psContour program (pseudo-contour) program uses SlopeField to
  85. produce a fast contour plot of the current function. By plotting the
  86. direction field perpendicular to the gradient of the function it
  87. allows your eye to pick out the integral curves (contours) without
  88. actually plotting them. The apparent contours are evenly spaced
  89. visually and so give no information on how steep the graph is at any
  90. particular point.
  91.  
  92. YView:
  93.      The YView program provides an oblique-view, perspective, 3D
  94. surface plot (viewing toward increasing Y). The program assumes that
  95. the variable VPAR contains the viewpoint coordinates, Xe, Ye, Ze,
  96. together with view-volume bounds, Yfar and Ynear. VPAR, then, is
  97. assumed to contain a list of numbers { Xe Ye Ze Yfar Ynear
  98. hidden-line-p } where hidden-line-p is non-zero if you wish to use the
  99. hidden-line facilities in the plot. If this is non-zero, RES (plotting
  100. resolution) should be set to 0, or #2 for best effect.  The XRNG and
  101. YRNG (really "ZRNG" in this case) are to be adjusted as usual.
  102.                                                     
  103.      This is a simple "divide-by-depth" method for perspective
  104. plotting where the viewplane is always 1 unit from the viewpoint and
  105. is parallel to the x-z plane. Since the perspective transformation in
  106. the case can be implemented by a simple change of coordinates,
  107. plotting individual sections is no slower than ordinary plots.
  108.  
  109.      Note: To abort this routine, press the [ON] key and then press
  110. the [ENTER] key.
  111.  
  112. ShapeToShade:                           
  113.      The ShapeToShade program plots the function as a Phong-shaded
  114. figure viewed from above with a light source in the "north west." It
  115. assumes that the variable DPAR contains sixteen 4x4 GROBS to serve as
  116. the dithering pattern. The dither patterns included are probably not the
  117. best possible: insights along these lines are most welcome.
  118.  
  119. Movie:
  120.      The Movie program plots 8 cross-sections of the function plot
  121. varying the Y-value from Yfar to Ynear (as recorded in VPAR, see
  122. YView). Having plotted these, it calls the utility program, uSMOV
  123. (utility-show-movie), to play these back in sequence repeatedly.
  124.  
  125.      Note: To abort this routine in the plotting phase, press the [ON]
  126. key and then press the [ENTER] key.  To end the movie press any key
  127. (e.g. [ENTER]).
  128.  
  129. uSMOV:
  130.  
  131.      The uSMOV (utility show-movie) program takes <n> grobs from the
  132. stack and shows them in sequence, thus producing a movie effect. It
  133. can be stopped with any key press.
  134.  
  135. _Correspondence_
  136.  
  137. Correspondence on Suite3D suite be sent to Charles Patton at one of the
  138. following addresses:
  139.  
  140. snail-mail:
  141.           M.S. 5U-L9
  142.           Hewlett-Packard Co.
  143.           1000 N.E. Circle Blvd.
  144.           Corvallis, OR 97330
  145.  
  146. e-mail:
  147.           charliep@cv.hp.com    (for Internet hosts)
  148.           hplabs!hpcvrs!charliep (for UUCP hosts)
  149.  
  150. END_DOC
  151. BYTES: #EEADh    3228.5
  152.  
  153. BEGIN_RPL Suite3D
  154. %%HP: T(3)A(R)F(.);
  155. DIR
  156.   SlopeField 
  157. \<< EQ
  158.    'PPAR(1)' EVAL C\->R 
  159.    'PPAR(2)' EVAL C\->R 
  160.    0 0 0 0 0 0 0 
  161.    \-> der left bot right top hstp vstp hofs vofs x y d
  162.   \<< ERASE { # 0d # 0d } PVIEW 
  163.       right left - 13 / 'hstp' STO 
  164.       top bot - 8 / 'vstp' STO 
  165.       hstp .4 * 'hofs' STO
  166.       vstp .4 * 'vofs' STO 
  167.       bot vstp 2 / + top
  168.     FOR y 
  169.         y 'Y' STO
  170.         left hstp 2 / + right
  171.       FOR x 
  172.           x 'X' STO 
  173.           der \->NUM 'd' STO 
  174.           'IFTE(ABS(d*hofs)>vofs,
  175.                 vofs/d+i*vofs,
  176.                 hofs+i*hofs*d)' \->NUM 
  177.          x y R\->C
  178.          DUP2 + 3 ROLLD SWAP - LINE 
  179.          hstp
  180.       STEP 
  181.       vstp
  182.     STEP
  183.   \>> {X Y} PURGE {} PVIEW
  184. \>>
  185.  
  186.   psContour
  187. \<< EQ
  188.   \<< \-> dx dy 'IFTE(dy==0,MAXR,-dx/dy)' \>> 
  189.   \-> eq slp
  190.   \<< IFERR
  191.         eq X \.d eq Y \.d 
  192.         2 \->LIST 'slp' APPLY 
  193.         {X Y } SHOW 
  194.         STEQ
  195.         SlopeField 
  196.       THEN 
  197.         eq STEQ
  198.         ERRM DOERR
  199.       END eq STEQ
  200.   \>>
  201. \>>
  202.  
  203.   YView
  204. \<< VPAR OBJ\-> 
  205. @ include the (optional) hidden-line routine: @
  206.   \<< \-> K 
  207.       \<< CASE K TYPE DUP 0 == 
  208.           THEN DROP
  209.            X K R\->C X -50 R\->C DUP2 
  210.                LINE TLINE
  211.                K
  212.       END
  213.       1 ==
  214.       THEN  K
  215.       END
  216.       K EVAL 1 \->LIST 'PRASE' APPLY
  217.       END
  218.        \>>
  219.  \>>
  220.     \-> Xe Ye Ze Yfar Ynear prase u hline
  221.   \<< 'EQ' RCL 'u' \-> eq u
  222.     \<< eq { 'X' '(X-Xe)*u+Xe' 'Y' 'u+Ye' } |
  223.     Ze - 'u' / Ze +
  224.     { X u } SHOW COLCT
  225.       IF prase
  226.       THEN { & 'hline(&)' } \|vMATCH DROP
  227.       END 
  228.       IFERR 
  229.          'EQ' STO
  230.      'X' INDEP ERASE
  231.      Ynear Yfar - 8 / 
  232.      \-> stp
  233.         \<<
  234.         Yfar Ye -
  235.         Ynear Ye -
  236.         FOR u 
  237.             DRAW 
  238.         IF
  239.           KEY
  240.             THEN
  241.               DROP
  242.           "outa here" DOERR
  243.             END stp
  244.        STEP 
  245.        \>>
  246.       THEN eq STEQ ERRM DOERR
  247.       ELSE eq STEQ
  248.       END {} PVIEW
  249.      \>>
  250.   \>>
  251. \>>
  252.  
  253.   VPAR
  254. { 0 -.5 2 3.5 -.2 0}
  255.  
  256.  ShapeToShade
  257.    \<< 'PPAR(1)' EVAL C\->R 
  258.        'PPAR(2)' EVAL C\->R 0 0 0
  259.        \-> xmin ymin xmax ymax x y eq
  260.        \<< xmax xmin - 32 / ymax ymin - 15 / 'x' 'y'
  261.           \-> xstp ystp x y
  262.       \<< EQ DUP X \.d .4 - 2 ^ SWAP
  263.           Y \.d .4 - 2 ^ + 
  264.           1 + -.5 ^ {X x Y y} | 'eq' STO
  265.               ERASE
  266.           { # 0d # 0d } PVIEW # 0d ymin ymax 
  267.           FOR y
  268.               # 0d xmin xmax
  269.           FOR x
  270.               DUP2 SWAP 2 \->LIST PICT SWAP 
  271.               eq \->NUM
  272.               IF DUP TYPE 0 \=/
  273.               THEN DROP 1
  274.               END 
  275.               15 * IP DPAR SWAP 
  276.               16 - NEG GET REPL
  277.               4 + xstp
  278.            STEP
  279.            DROP 4 + ystp
  280.            STEP DROP
  281.               {} PVIEW
  282.      \>>
  283.      \>>
  284.   \>>
  285.  
  286.  DPAR
  287.    { GROB 4 4 00400000
  288.      GROB 4 4 00402000
  289.      GROB 4 4 00604000
  290.      GROB 4 4 00606000
  291.      GROB 4 4 00606010
  292.      GROB 4 4 10606080
  293.      GROB 4 4 90606080
  294.      GROB 4 4 90606090
  295.      GROB 4 4 60909070
  296.      GROB 4 4 E0909070
  297.      GROB 4 4 F09090E0
  298.      GROB 4 4 F09090F0
  299.      GROB 4 4 F090B0F0
  300.      GROB 4 4 F0B0D0F0
  301.      GROB 4 4 F0B0F0F0
  302.      GROB 4 4 F0F0F0F0 
  303.    }
  304.  
  305.   Movie
  306. \<< PPAR EQ 'VPAR(4)' EVAL 'VPAR(5)' EVAL 0 0
  307.     \-> ppar eq yfar ynear ystp y
  308.     \<< 'y' 'y' STO
  309.         eq {X Y} SHOW {Y y} |
  310.         ynear yfar - 8 / 'ystp' STO
  311.         IFERR
  312.           STEQ
  313.           'X' INDEP
  314.           FUNCTION
  315.           0 yfar ynear 
  316.           FOR y
  317.             ERASE DRAW PICT RCL SWAP 1 +
  318.             IF KEY 
  319.             THEN DROP "outa here" DOERR 
  320.             END
  321.             ystp
  322.           STEP
  323.         THEN
  324.           ppar 'PPAR' STO
  325.           eq STEQ
  326.           ERRM DOERR
  327.         END
  328.         ppar 'PPAR' STO
  329.         eq STEQ
  330.     \>> uSMOV
  331. \>>
  332.  
  333.  uSMOV
  334. \<< \-> n
  335.     \<< {#0 #0} PVIEW
  336.         DO
  337.           n ROLL DUP PICT {#0 #0} ROT REPL
  338.         UNTIL
  339.           KEY
  340.         END DROP
  341.         n
  342.     \>>
  343. \>>
  344.  
  345.  EQ
  346. '(Y^2*X-X^3)*.2'
  347.  
  348.  PPAR
  349. { (-6.5,-3.1) (6.5,3.2) X # 4d (0,0) FUNCTION Y }
  350.  
  351. END
  352. END_RPL
  353.